package com.dgsrz.demo.util;

import android.util.Log;

/**
 * Simple FPS Logger
 *
 * @author dgsrz
 */
public enum FPSLogger {

    INSTANCE;

    private long mLastCheckpoint;
    private int  mFinishedFrames;

    FPSLogger() {
        mLastCheckpoint = System.currentTimeMillis();
    }

    public void finishGLDraw() {
        mFinishedFrames++;
        long currentTime = System.currentTimeMillis();
        if (currentTime - mLastCheckpoint >= 1000) {
            Log.d("FPSLogger", "FPS: " + mFinishedFrames);
            mFinishedFrames = 0;
            mLastCheckpoint = currentTime;
        }
    }
}
